{extend name="public/base"}

{block name="title"}
{$repair.repair_name|default='(无名)'} 店铺信息
{/block}


{block name="style"}
<link rel="stylesheet" href="/static/wechat/css/homepage.css" />
<style type="text/css">
	#container .amap-marker .amap-icon img{width:auto;height:auto;}
	.weui-popup__overlay{opacity:1;}
	.weui-dialog__btn{color:#0bb20c;font-size:0.8rem;}
	.weui-dialog, .weui-toast{box-shadow:0 0 3px 0 #000;}
	.msg_panel,.msg_success{position:fixed;top:0px;left:100%;width:100%;height:100%;background:#fff;overflow:auto;}
	.del_uploads_tip{clear:both;text-align:center;font-size:12px;color:#999;line-height:1rem;}
	.basic_mesg{margin-top:0.6rem;}
	.now_order{position:fixed;left:0;bottom:0;text-align: center;line-height: 2.5rem;}
	#c_list_box .weui-cells{background:#fff;padding-bottom:1rem;margin-top:0;border:none;}
	#c_list_box .weui-cells .weui-cell .weui-cell__ft{position:absolute;right:0;margin-top:0rem;}
</style>
<script>
	function get_level_star(n){
		var n = parseInt(n);
		var tmpStar = '';
		if(!n){
			tmpStar = '<i></i><i></i><i></i><i></i><i></i>';
		}else if(n==1){
			tmpStar = '<i></i>';
		}else if(n==2){
			tmpStar = '<i></i><i></i>';
		}else if(n==3){
			tmpStar = '<i></i><i></i><i></i>';
		}else if(n==4){
			tmpStar = '<i></i><i></i><i></i><i></i>';
		}else if(n==5){
			tmpStar = '<i></i><i></i><i></i><i></i><i></i>';
		}
		return tmpStar;
	}

	function getWeekStr(s){
		var weekStrArr = "周日/周一/周二/周三/周四/周五/周六".split("/");
		var weekArr = s.split(',');
		var weekStr = "";
		for(i=0;i<weekArr.length;i++){
			if(weekArr[i]){
				weekStr += weekStrArr[parseInt(weekArr[i])]+"&nbsp;&nbsp;";
			}
		}
		return weekStr;
	}

	var EARTH_RADIUS = 6378137.0;    //单位M
	var PI = Math.PI;
	function getRad(d){return d*PI/180.0;}
	function getFlatternDistance(lat1,lng1,lat2,lng2){
		var f = getRad((lat1 + lat2)/2);
		var g = getRad((lat1 - lat2)/2);
		var l = getRad((lng1 - lng2)/2);
		var sg = Math.sin(g);
		var sl = Math.sin(l);
		var sf = Math.sin(f);
		var s,c,w,r,d,h1,h2;
		var a = EARTH_RADIUS;
		var fl = 1/298.257;
		sg = sg*sg;
		sl = sl*sl;
		sf = sf*sf;
		s = sg*(1-sl) + (1-sf)*sl;
		c = (1-sg)*(1-sl) + sf*sl;
		w = Math.atan(Math.sqrt(s/c));
		r = Math.sqrt(s*c)/w;
		d = 2*w*a;
		h1 = (3*r -1)/2/c;
		h2 = (3*r +1)/2/s;
		var tmpReturn = d*(1 + fl*(h1*sf*(1-sg) - h2*(1-sf)*sg));
		return (tmpReturn?tmpReturn:0);
	}

</script>
{/block}

{block name="body"}
<div class="pageControl orderDetails">
	<div class="msui_nav msui_navTop" style="border-bottom: 1px solid #cccccc;">
		<a class="msui_navTop-back" href="javascript:history.back();"><i class="micon-back"></i></a>
		<h1 class="msui_navTop-title">店铺信息</h1>
	</div>
	<div class="weui-top">
		<!--店铺基本信息-->
		<div class="basic_mesg">

			<i class="shop_head" style="background-image:url({$repair.logo|default=''})">

			</i>
			<div class="basic_div">
				<h1>{$repair.repair_name|default='(无名)'}</h1>
				<script>document.write(get_level_star("{$repair.level_avg|default=''}"))</script>
				<span class="consu">{$repair.order_count|default=0}人已消费</span>
			</div>

		</div>


		<!--地址联系方式-->
		<div class="weui-cells weui-nopdbt">
			<div class="weui-cell">
				<div class="weui-cell__hd"><img class="icon" src="/static/wechat/images/dianpu_10.png"></div>
				<div class="weui-cell__bd" style="width:66%;flex:initial;">
					<p>{$repair.address|default=''}</p>
				</div>
				<div class="weui-cell__ft" style="margin-top:0rem;">距你约<span id="s_juli_box"></span>m</div>
			</div>
			<div class="weui-cell" style="padding: 10px 15px;">
				<div class="weui-cell__hd"><img class="icon" src="/static/wechat/images/dianpu_13.png"></div>
				<div class="weui-cell__bd">
					<p>{$repair.phone|default=''}</p>
				</div>
				<div class="weui-cell__ft"></div>
			</div>
		</div>
		<!--营业时间-->
		<div class="weui-cells weui-nopdbt">
			<div class="weui-cell" style="padding: 15px 15px;">
				<div class="weui-cell__hd"></div>
				<div class="weui-cell__bd">
					<p id="jytime">经营时间</p>
				</div>
			</div>
			<div class="weui-cell" style="padding: 15px 15px;">
				<div class="weui-cell__hd"></div>
				<div class="weui-cell__bd">
					<p class="data"><script>document.write(getWeekStr("{$repair.week|default=''}"));</script></p>
					<br />
					<p class="data">{$repair.open_time?substr($repair.open_time,0,5):''}~{$repair.open_time?substr($repair.close_time,0,5):''}</p>
				</div>
			</div>
		</div>
		<!--经营项目-->
		<div class="weui-cells weui-nopdbt">
			<div class="weui-cell" style="padding: 15px 15px;">
				<div class="weui-cell__hd"></div>
				<div class="weui-cell__bd">
					<p id="jytime">经营项目</p>
				</div>
			</div>
			<div class="weui-cell" style="padding: 20px 15px;">
				<div class="weui-cell__hd"></div>
				<div class="weui-cell__bd">

					{volist name="repair.item" id="v"}
				<span class="kind"
					  {notempty name='v.r_id'}style="display:;"{else}style="display:none"{/notempty}
					>{$v.item_name}</span>
					{/volist}
				</div>
			</div>
		</div>
		<!--实景图片-->
		<div class="weui-cells weui-nopdbt">
			<div class="weui-cell" style="padding: 15px 15px;">
				<div class="weui-cell__hd"></div>
				<div class="weui-cell__bd">
					<p id="jytime">实景图片</p>
				</div>
			</div>
			<div class="weui-cell" style="padding: 15px 15px;">
				<div class="weui-cell__hd"></div>
				<div class="weui-cell__bd">
					<!--<div class="images-wrapper">-->
					<!--<img src="/static/wechat/images/1.jpg"/>-->
					<!--<div class="images-content">-->
					<!--店内环境-->
					<!--</div>-->
					<!--</div>-->
					{notempty name='repair.environment_img1'}
					<div class="images-wrapper"><img class="s_environment_img" src="{$repair.environment_img1}" /></div>
					{/notempty}
					{notempty name='repair.environment_img2'}
					<div class="images-wrapper"><img class="s_environment_img" src="{$repair.environment_img2}" /></div>
					{/notempty}
					{notempty name='repair.environment_img3'}
					<div class="images-wrapper"><img class="s_environment_img" src="{$repair.environment_img3}" /></div>
					{/notempty}
					{notempty name='repair.environment_img4'}
					<div class="images-wrapper"><img class="s_environment_img" src="{$repair.environment_img4}" /></div>
					{/notempty}
					{notempty name='repair.environment_img5'}
					<div class="images-wrapper"><img class="s_environment_img" src="{$repair.environment_img5}" /></div>
					{/notempty}
					{notempty name='repair.environment_img6'}
					<div class="images-wrapper"><img class="s_environment_img" src="{$repair.environment_img6}" /></div>
					{/notempty}
					{notempty name='repair.environment_img7'}
					<div class="images-wrapper"><img class="s_environment_img" src="{$repair.environment_img7}" /></div>
					{/notempty}
					{notempty name='repair.environment_img8'}
					<div class="images-wrapper"><img class="s_environment_img" src="{$repair.environment_img8}" /></div>
					{/notempty}
				</div>
			</div>
		</div>
		<!--店铺评价-->
		<div class="weui-cells weui-nopdbt">
			<a class="weui-cell weui-cell_access" style="padding: 10px 15px;padding-bottom: 0;" href="javascript:;">
				<div class="weui-cell__bd" id="weui_flex">
					<p class="ping_num">评价<span>({$repair.level_count?$repair.level_count:'0'})</span></p>
					<span>{$repair.level_avg?number_format($repair.level_avg,1,'.',''):''}</span>
					<div class="P_star">
						{$repair.level_avg?str_repeat('<i></i>',ceil($repair.level_avg)):'<i></i><i></i><i></i><i></i><i></i>'}
					</div>

				</div>
				<div class="weui-cell__ft">
				</div>
			</a>
		</div>
		<!--评价标签-->
		<div class="tag">
			{volist name="repair.labels" id="vo"}
			<p>{$vo.label}<span class="tag_nunmer">({$vo.num})</span></p>
			{/volist}
		</div>
		<!--用户评论-->
		<div id="c_list_box">

		</div>

		<!--立即下单-->
		<div style="height:3rem;"><!--占位--></div>
		<a href="javascript:;" class="open-popup now_order" data-target="#Pop">立即下单</a>
		<div id="Pop" class="weui-popup__container popup-bottom">
			<div class="weui-popup__overlay"></div>
			<div class="weui-popup__modal" style="background-color:transparent ;text-align: center;">
				<div class="parele">
					<div class="Servise_time">
						<span>服务时间</span>
						<!--<h1 class="fs07">现在</h1>-->
						<input class="weui-input" id="time-format" type="text" placeholder="现在">
					</div>
					<!--定位到区-->
					<div class="Servise_addres" style="display:none;">
						<i></i>
						<form onsubmit="return false">
							<input id="start" class="Servise_input" type="text" placeholder="获取省市区..." />
						</form>
					</div>
					<div class="Servise_addres" style="display:none;">
						<i></i>
						<form onsubmit="return false">
							<input id="sJiedao" class="Servise_input" placeholder="获取街道..." value="" />
						</form>
					</div>
					<div class="Servise_addres">
						<i></i>
						<form onsubmit="return false" style="width:100%;">
							<input id="sAdd" class="Servise_input" placeholder="填写详细地址" value="" />
						</form>
					</div>
					<div class="Servise_description1" style="display:none">
						<i class="ipt_yuan"></i>
						<form onsubmit="return false">
							<input id="sName" class="Servise_input" placeholder="填写联系人" value="{$member.proposer|default=$member.nickname|default=''}" />
						</form>
					</div>
					<div class="Servise_description1" style="display:none">
						<i class="ipt_yuan"></i>
						<form onsubmit="return false">
							<input id="sTel" class="Servise_input" placeholder="填写联系方式" value="{$member.phone0|default=$member.phone|default=''}" />
						</form>
					</div>
					<div class="Servise_description1">
						<i class="ipt_yuan"></i>
						<form onsubmit="return false">
							<select id="in_type" class="Servise_input">
								{volist name="repair.item" id="v"}
								{eq name="v.display" value="1"}
								<option value="{$v.id}">{$v.item_name}</option>
								{/eq}
								{/volist}
							</select>
						</form>
					</div>
					<div class="Servise_description1">
						<i class="ipt_yuan"></i>
						<form onsubmit="return false">
							<input id="sMsg" class="Servise_input" placeholder="问题描述(可选)" value="" />
						</form>
					</div>
					<!--<div class="Servise_description1">-->
					<!--<i class="ipt_yuan"></i>-->
					<!--<form onsubmit="return false">-->
					<!--<input id="sDateTimeLocal" placeholder="日期时间" value="" type="datetime-local" />-->
					<!--</form>-->
					<!--</div>-->
					<div class="Servise_description2">
						<!--<span>上门服务</span>-->
						<input class="weui-input" id="mobile" type="text" value="" placeholder="上门处理">

						<div></div>
						<!--<span>添加图片</span>-->
						<a href="javascript:;" class="open-popup" data-target="#Popup2" id="add_img_but">添加图片</a>
					</div>
				</div>
				<div class="transparent_">

				</div>
				<button class="Servise_placeorder fs08 close-popup" disabled="disabled">
					确认下单
				</button>
			</div>
		</div>

		<!--图片弹出框-->
		<div id="Popup2" class="weui-popup__container popup-bottom">
			<div class="weui-popup__overlay"></div>
			<div class="weui-popup__modal">
				<div class="navbar">
					<div class="msui_nav msui_navTop" style="border-bottom: 1px solid #cccccc;">
						<a class="msui_navTop-back open-popup" data-target="#Pop"><i class="micon-back"></i></a>
						<h1 class="msui_navTop-title">添加图片</h1>
					</div>

					<div class="tjimg">
						<!--<img src="/static/wechat/images/1.jpg"/>-->
						<div class="weui-uploader__input-box" id="marg">
							<input id="uploaderInput" class="weui-uploader__input" type="file" accept="image/*" file-attr="" />
						</div>
					</div>

					<button class="tjtu open-popup" data-target="#Pop">确认</button>
					<p style="clear:both;text-align:center;font-size:12px;color:#999;line-height:1rem;">（长按图片删除）</p>

				</div>
			</div>
		</div>
	</div>
</div>

<div id="container" tabindex="0" style="display:none"></div>
<!--weui-->
<div id="loadingToast" style="display:none;">
	<div class="weui-mask_transparent"></div>
	<div class="weui-toast">
		<i class="weui-loading weui-icon_toast"></i>
		<p class="weui-toast__content">数据加载中...</p>
	</div>
</div>
<div id="iosDialog2" class="js_dialog" style="display:none;">
	<div class="weui-mask_transparent"></div>
	<div class="weui-dialog">
		<div class="weui-dialog__bd">弹窗内容，告知当前状态、信息和解决方法，描述文字尽量控制在三行内</div>
		<div class="weui-dialog__ft">
			<a href="javascript:$('#iosDialog2').hide();" class="weui-dialog__btn weui-dialog__btn_primary">知道了</a>
		</div>
	</div>
</div>
<div class="page msg_success js_show">
	<div class="weui-msg">
		<div class="weui-msg__icon-area"><i class="weui-icon-success weui-icon_msg"></i></div>
		<div class="weui-msg__text-area">
			<h2 class="weui-msg__title">下单成功</h2>
			<p class="weui-msg__desc">请等待商家推送服务给您...</p>
		</div>
		<div class="weui-msg__opr-area">
			<p class="weui-btn-area">
				<a href="{:url('orders/index')}" class="weui-btn weui-btn_primary">查看我的订单</a>
				<!--<a href="javascript:history.back();" class="weui-btn weui-btn_default">辅助操作</a>-->
			</p>
		</div>
	</div>
</div>
{/block}


{block name="javascript"}<!--jquery-city-picker.min.js-->

<script type="text/javascript" src="/static/wechat/jquery_weui/js/data-picker1.js" ></script>
<script type="text/javascript" src="/static/wechat/jquery_weui/js/city-picker.js" ></script>
<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=9a8d0d7e358d9d80f7f61a1989ba35a0"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script>
	wx.config({
		//debug: true,
		appId: '{$signPackage.appId}',
		timestamp: parseInt('{$signPackage.timestamp}'),
		nonceStr: '{$signPackage.nonceStr}',
		signature: '{$signPackage.signature}',
		jsApiList: [
			// 所有要调用的 API 都要加到这个列表中
			'previewImage'
		]
	});
	//wx.previewImage({current:tmpArr[0],urls:tmpArr});
</script>

<!-- PJ 0 -->
<script type="text/javascript">
	//改写原生的对话框
	function sAlert(s){
		$('#iosDialog2').show();
		$('#iosDialog2 .weui-dialog__bd').html(s);
	}
	window.alert = function(s){sAlert(s);}

	//处理定位信息
	function onComplete(data){
		$('#loadingToast').fadeOut();
		if(data.info=="SUCCESS"){
			window.my = data;

			$("#start").attr("value",window.my.addressComponent.province+" "+window.my.addressComponent.city+" "+window.my.addressComponent.district);
			var tmpDZ = window.my.formattedAddress;
			tmpDZ = tmpDZ.substr(tmpDZ.indexOf("省")+1);
			tmpDZ = tmpDZ.substr(tmpDZ.indexOf("市")+1);
			tmpDZ = tmpDZ.substr(tmpDZ.indexOf("区")+1);
			tmpDZ = tmpDZ.replace(window.my.addressComponent.township,"");
			$("#sAdd").val(tmpDZ);
			$('#s_juli_box').text( getFlatternDistance(window.my.position.lat,window.my.position.lng,parseFloat('{$repair.lat}'),parseFloat('{$repair.lon}')).toFixed(0) );

			$("#start").cityPicker({
				title: "选择省，市，区",
				onChange: function (picker, values, displayValues) {
					return true;
				},
				onClose: function(r1){
					//console.log(r1);
					$("#sJiedao").val("");
					$("#sJiedao").attr("data","");

					$('#loadingToast').fadeIn();
					$.ajax({
						type:"get",
						cache:false,
						dataType:"json",
						url:"{:url('Base/get_street')}?area="+r1.value[2]+"",
						error:function(s){
							$('#loadingToast').fadeOut();
							alert('网络异常');
						},
						success:function(d){
							$('#loadingToast').fadeOut();
							if(d.code!=200){
								alert(d.msg);
							}else{

								var tmp_values = new Array();
								var tmp_displayValues = new Array();
								for(i=0;i<d.data.length;i++){
									tmp_values[i] = d.data[i].region_id;
									tmp_displayValues[i] = d.data[i].region_name;
									if(window.my.addressComponent.township==tmp_displayValues[i]){
										$("#sJiedao").attr("value",tmp_displayValues[i]);
										$("#sJiedao").attr("data",tmp_values[i]);
										$("#sJiedao").val(tmp_displayValues[i]);
									}
								}

								try{
									$("#sJiedao").data().picker.cols[0].values = tmp_values;
									$("#sJiedao").data().picker.cols[0].displayValues = tmp_displayValues;
								}catch(e){
									$("#sJiedao").picker({
										title: "请选择街道",
										cols: [
											{
												textAlign: 'center',
												values: tmp_values,
												displayValues: tmp_displayValues
											}
										],
										onChange: function (picker, values, displayValues) {
											return true;
										},
										onClose: function(r2) {
											try{
												$("#sJiedao").val(r2.displayValue[0]);
												$("#sJiedao").attr("data",r2.value[0]);
											}catch(e){}
											//console.log(r2);
										}
									});
								}
								//获取一下街道对应的data-codes
								//$("#sJiedao").data().picker.open();$("#sJiedao").data().picker.close();

							}
						}
					});

				}
			});
			//获取一下省市区对应的data-codes
			$("#start").data().picker.open();$("#start").data().picker.close();


		}else{
			alert("没有成功获取到您的位置<br>请重新访问...<br>(" + data.message + ")");
		}

	}
	//处理定位出错信息
	function onError(e){
		$('#loadingToast').fadeOut();
		alert("无法获取您的位置<br>请重新访问...<br>(" + e.message + ")");
	}

	//长按删除图片
	function del_uploads_img(o){
		window.t_img = o;
		window.t_uploads = setTimeout(function(){
			if(window.confirm("确定删除?")){
				var formData = new Object();
				formData.img = window.t_img.src.split(window.location.host)[1];
				$.ajax({
					url: '{:url("Base/del_upload_img")}' ,
					type: 'POST',
					data: formData,
					dataType:"json",
					success: function (d) {
						if(d.code==200){
							window.t_img.parentNode.removeChild(window.t_img);
						}else{
							alert('无法删除文件');
						}
					},
					error: function (d) {
						alert('网络异常');
					}
				});

			}
		},666);
	}
	//取消长按删除图片
	function del_uploads_img_clear(){
		window.clearTimeout(window.t_uploads);
	}


	var mapObj,geolocation,dragTime;
	window.my = new Object();//存放用户的定位信息


	//初始化地图
	mapObj = new AMap.Map('container',{
		resizeEnable: true,
		zoom: 15,
		//zoomEnable: false,	//禁止放大缩小
		//dragEnable: false,	//禁止拖动
		mapStyle:'fresh'
	});


	//笤俑微信原生查看环境图片
	$('img.s_environment_img').click(function(){
		var tmpArr = new Array();
		for(i=0;i<$('img.s_environment_img').length;i++){
			tmpArr[i] = $('img.s_environment_img')[i].src;
		}
		wx.previewImage({current:$(this)[0].src,urls:tmpArr});
	});

	var check_uploads_img = window.setInterval(function(){
		var num = $(".tjimg img").length;
		if(num){
			$('#add_img_but').html('有'+num+'张图片');
		}else{
			$('#add_img_but').html('添加图片');
		}
	},999);

	$('.ipt_yuan').addClass('input_yuan2');
	$('.Servise_placeorder').addClass('Servise_placeorder2').removeAttr('disabled');

	//弹出框和选择日期
	$("#mobile").picker({
		title: "请选择服务方式",
		cols: [
			{
				textAlign: 'center',
				values: ['上门处理', '到店处理']
			}
		],
		onChange: function(p, v, dv) {
			console.log(p, v, dv);
		},
		onClose: function(p, v, d) {
			console.log("close");
		}
	});

	$("#time-format").datetimePicker({
		title: '请选择服务时间',
		yearSplit: '年',
		monthSplit: '月',
		dateSplit: '日',
		times: function () {
			return [  // 自定义的时间
				{
					values: (function () {
						var hours = [];
						for (var i=0; i<24; i++) hours.push(i > 9 ? i : '0'+i);
						return hours;
					})()
				},
				{
					divider: true,  // 这是一个分隔符
					content: '时'
				},
				{
					values: (function () {
						var minutes = [];
						for (var i=0; i<59; i++) minutes.push(i > 9 ? i : '0'+i);
						return minutes;
					})()
				},
				{
					divider: true,  // 这是一个分隔符
					content: '分'
				}
			];
		},
		onChange: function (picker, values, displayValues) {
			console.log(values);
		}
	});

	//添加图片
	$("#uploaderInput").change(function(){
		if($(".tjimg img").length>4){
			alert('只能添加5张图片');
		}else{
			$('#loadingToast').fadeIn();
			window.setTimeout(function(){
				var formData = new FormData();
				formData.append("type","order");
				formData.append("img",$("#uploaderInput")[0].files[0]);
				$.ajax({
					url: '{:url("Base/get_upload_img")}' ,
					type: 'POST',
					data: formData,
					async: false,
					cache: true,
					contentType: false,
					processData: false,
					dataType:"json",
					success: function (d) {
						if(!d.code){
							alert(d.msg);
						}else{
							$(".tjimg").prepend('<img src="'+d.data.path+'" ontouchstart="del_uploads_img(this)" ontouchend="del_uploads_img_clear()" />');
						}
						$('#loadingToast').fadeOut();
					},
					error: function (d) {
						alert('网络异常');$('#loadingToast').fadeOut();
					}
				});
			},666);

		}
	});


	//确认下单
	window.Servise_placeorder_check = true;
	$(".Servise_placeorder").click(function(){

		var formData = new Object();
		formData.repair_id = '{$repair.id|default=0}';
		var tmpTime = $("#time-format").val().replace("年","-").replace("月","-").replace("日","").replace("时",":").replace("分","");
		formData.server_time = tmpTime;
		var tmpMode = ($("#mobile").val()=="到店处理"?1:2);
		formData.service_mode = tmpMode;
		formData.msg = $("#sMsg").val();
		formData.address = $("#sAdd").val();
		formData.apply_person = $("#sName").val();
		formData.phone = $("#sTel").val();
		formData.type = $("#in_type").val();
		formData.lng = window.my.position.lng;
		formData.lat = window.my.position.lat;
		try{
			formData.province = $("#start").attr("data-codes").split(",")[0];
			formData.city = $("#start").attr("data-codes").split(",")[1];
			formData.area = $("#start").attr("data-codes").split(",")[2];
			formData.street = $("#sJiedao").attr("data");
		}catch(e){}
		formData.img1 = formData.img2 = formData.img3 = formData.img4 = formData.img5 = "";
		for(i=0;i<$(".tjimg img").length;i++){
			eval("formData.img"+(i+1)+" = '"+$(".tjimg img")[i].src.split(window.location.host)[1]+"';");
		}

		if(formData.address.length<3){alert("请输入详细地址");return false;}
		//if(formData.apply_person.length<1){alert("请输入联系人");return false;}
		//if(formData.phone.length<6){alert("请输入联系方式");return false;}
		//if(formData.msg.length<2){alert("请输入问题描述");return false;}

		$('#loadingToast').fadeIn();
		if(window.Servise_placeorder_check==false){
			return false;
		}
		window.Servise_placeorder_check = false;
		$.ajax({
			url:"{:url('index/up_data')}",
			type: 'POST',
			data: formData,
			dataType:"json",
			error:function(s){
				window.Servise_placeorder_check = true;
				alert('网络异常');
				$('#loadingToast').fadeOut();
			},
			success:function(d){
				window.Servise_placeorder_check = true;
				if(d.code!=200){
					var code = msg.code;
					$.alert(error_code[code]);
				}else{
					$(".msg_success").animate({"left":"0px","display":"block"},200);
					//window.location.href = "order?id=" + d.data;
				}
				$('#loadingToast').fadeOut();
			}
		});

	});
	//解决iphone下单时无法关闭问题
	$(".weui-popup__overlay").click(function(){
		return true;
	});


	$(function () {

		$('#loadingToast').fadeIn();
		//监控用户位置
		mapObj.plugin('AMap.Geolocation', function () {
			geolocation = new AMap.Geolocation({
				enableHighAccuracy: true,//是否使用高精度定位，默认:true
				timeout: 30000,          //超过30秒后停止定位，默认：无穷大
				maximumAge: 0,           //定位结果缓存0毫秒，默认：0
				convert: true,           //自动偏移坐标，偏移后的坐标为高德坐标，默认：true
				showButton: true,        //显示定位按钮，默认：true
				buttonPosition: 'LB',    //定位按钮停靠位置，默认：'LB'，左下角
				buttonOffset: new AMap.Pixel(10,10),//定位按钮与设置的停靠位置的偏移量，默认：Pixel(10, 20)
				showMarker: true,        //定位成功后在定位到的位置显示点标记，默认：true
				showCircle: false,        //定位成功后用圆圈表示定位精度范围，默认：true
				panToLocation: true,     //定位成功后将定位到的位置作为地图中心点，默认：true
				zoomToAccuracy:true,      //定位成功后调整地图视野范围使定位位置及精度范围视野内可见，默认：false
				extensions:'base'
			});
			//markerOptions: window.my_dingdan,
			mapObj.addControl(geolocation);//开始监控
			AMap.event.addListener(geolocation, 'complete', onComplete);//返回定位信息//onComplete
			AMap.event.addListener(geolocation, 'error', onError);      //返回定位出错信息
			$(".amap-geo").trigger("click");
		});

		function get_comment_list() {
			$('#loadingToast').fadeIn();
			obj.is_more = false;
			$.ajax({
				type : 'POST',
				url : obj.url + '?page=' + obj.page,
				data : {
					repair_id : "{$repair.id|default='0'}"
				},
				dataType : 'json',
				error : function (msg) {
					$('#loadingToast').fadeOut();
					alert('网络异常');
				},
				success : function (msg) {
					$('#loadingToast').fadeOut();
					if (obj.page == 1) {
						$("#c_list_box").html(msg.tpl);
					} else {
						$("#c_list_box").append(msg.tpl);
					}
					// 计算是否还有更多数据
					if ((msg.data.total - (msg.data.current_page * msg.data.per_page)) > 0) {
						obj.is_more = true;
					}
					obj.page++;
				}
			});
		}

		var obj = {
			'is_more' : true,
			'page' : 1,
			'url' : '{:url("get_comment_list")}',
		};

		get_comment_list();
		$(window).scroll( function() {
			if (($(document).height() - $(this).scrollTop() - $(this).height()<50) && obj.is_more){
				get_comment_list();
			}
		});

	});

</script>
{/block}
